﻿@using PAMD
@using PAMD.Business.Models
@model PAMD.Business.Models.ListAllModel
@{
    ViewBag.Title = SiteConstant.Slogan;
    Layout = "../Shared/_Layout.cshtml";
}
@using (Html.BeginForm("AddNewSave", "Listing"))
{
    <div class="form-container-small">
        <strong>Your listings</strong>
        <fieldset class="field-container">
            <div>
                @if (ViewBag.Error != null && ViewBag.Error != "")
                {
                    <div class="red-box">
                        @ViewBag.Error
                    </div>
                }
                <!--  ========================== search result ==========================   -->
                <div class="left-align">
                    <div class="controlBox">
                        <label style="width: 300px">
                            Your listings</label>
                        <input type="submit" class="right-align" value="Add new" />
                    </div>
                </div>
                <div class="left-align line-divider-lightblue">
                    &nbsp;
                </div>
                <!--  ========================== Title ==========================   -->
                @foreach (var listing in Model.Result)
                {            
                    var photo = listing.Photo.Where(p => p.IsPrimary).FirstOrDefault();     
                    <div class="left-align">
                        <div class="controlBox">
                            <div style="width: 100%; text-align: right; background-color: #f5f5f5;">
                                @Html.ActionLink("10 Available", "View", "Listing", new { @id = listing.Listing.ID }, null)
                                &nbsp;&nbsp;&nbsp;@Html.ActionLink("3 Enquiries", "View", "Listing", new { @id = listing.Listing.ID }, null)&nbsp;&nbsp;&nbsp;
                                @Html.ActionLink("Change", "Edit", "Listing", new { @id = listing.Listing.ID }, null)&nbsp;&nbsp;&nbsp;
                                @Html.ActionLink(listing.Listing.IsActive ? "Deactivate" : "Activate", "Edit", "Listing", new { @id = listing.Listing.ID }, null)
                                &nbsp;&nbsp;&nbsp;
                            </div>
                            <div style="width: 100%; text-align: justify; min-height: 110px;">
                                <p>
                                    <img src='@Url.Content(string.Format("~/ListingPicture/{0}", photo != null ? photo.FileName : ""))' 
                                                class="roundimage1" alt="@listing.Listing.Title" />
                                    <h6>@Html.ActionLink(listing.Listing.Title, "View", "Listing", new { @id = listing.Listing.ID }, null)</h6>
                                    <br />
                                    @listing.Listing.SpaceDescription</p>
                            </div>
                            <hr />
                        </div>
                    </div>                       
                }
            </div>
        </fieldset>
    </div>
}